const express = require("express")
const cors = require("cors")
const morgan = require("morgan")
const config = require("./config")
const app = express()
app.use(express.json())
// 托管静态资源
app.use(express.static('public'))
//处理跨域
app.use(cors())
//处理日志
app.use(morgan("dev"))
// 引入路由中间件
app.use("/api", require("./routes"))
// 引入错误处理中间件
app.use(require("./middleware/error"))
app.listen(config.app.port, () => {
    console.log("Server is running on port 3000")
})